package com.flash.BusinessParameters.controller;

import com.flash.BusinessParameters.entity.FundSetting;
import com.flash.BusinessParameters.service.impl.FundSettingServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 基金设置
 */
@Controller
public class FundSettingController {
    public String toSysRight(){
        return "FundSetting";
    }

    @Autowired
    private FundSettingServiceImpl fundSettingServiceImpl;

    @RequestMapping("/selectFundSettingMap")
    @ResponseBody
    public Map selectFundSettingMap(FundSetting fundSetting, int page, int limit, HttpServletRequest request){
        List<FundSetting> fundSettingList = fundSettingServiceImpl.selectFundSettingMap(fundSetting, page, limit);
        int count = fundSettingServiceImpl.selectCountFundSetting();
        System.out.println("1111111"+fundSetting);
        HttpSession session = request.getSession();
        for (FundSetting f:fundSettingList) {
            session.setAttribute("fundId",f.getFundId());
            session.setAttribute("cashId",f.getCashId());
        }
        Map map =new HashMap();
        map.put("code","");
        map.put("msg","");
        map.put("count",count);
        map.put("data",fundSettingList);
        System.out.println(map);
        return map;
    }
    @RequestMapping("deleteFundSetting/{fundId}")
    @ResponseBody
    public int deleteFundSetting(@PathVariable int fundId){
        System.out.println("这是删除基金设置");
        System.out.println(fundId);
        return  fundSettingServiceImpl.deleteFundSetting(fundId);
    }
    @RequestMapping("/insertFundSetting")
    @ResponseBody
    public int insertFundSetting(FundSetting fundSetting){
        return fundSettingServiceImpl.insertFundSetting(fundSetting);
    }

    @RequestMapping("/updateFundSetting")
    @ResponseBody
    public int updateFundSetting(FundSetting fundSetting){
        System.out.println("这是修改");
        return fundSettingServiceImpl.updateFundSetting(fundSetting);
    }
    @RequestMapping("/selectFundSetting")
    @ResponseBody
    public List<FundSetting> selectFundSetting(){
        System.out.println("这是查询全部");
        return fundSettingServiceImpl.selectFundSetting();
    }

}
